package org.openems.osa;

import java.util.Arrays;

import org.openems.entity.ChoiceEntity;
import org.openems.entity.NumericEntity;
import org.openems.entity.Unit;

import framework.AbstractDomainService;
import framework.DomainService;
import framework.EntityResigter;
import framework.webclient.ProxyData;
import framework.webclient.RestSocket;
import framework.webclient.RestSocketImpl;
import framework.webclient.SystemProperty;
import framework.webserver.WebHandler;

public class OsaDomainService extends AbstractDomainService implements
		DomainService {

	private SystemProperty systemProperty = new SystemProperty() {

		@Override
		public String getProductName() {
			return "MS9740A";
		}

		@Override
		public String getSerialNumber() {
			return "SN123321123";
		}

		@Override
		public String getApplicationType() {
			return "Otdr";
		}
		
	};

	@Override
	public boolean isOnline() {
		return false;
	}

	@Override
	protected SystemProperty getSystemProperty() {
		return systemProperty;
	}

	@Override
	protected void initialize() {
		
	}

	@Override
	protected void registerDefaultEntities(EntityResigter defaultSetter) {
		OSAID id = OSAID.get();
		defaultSetter.registerEntity(new NumericEntity(id.CENTERWAVELENGTH, "Center Wavelength", 2, Unit.meter(), 0.6e-9, 1.8e-9, true));
		defaultSetter.registerEntity(new ChoiceEntity(id.VBW, "VBW", Arrays.asList("10Hz", "100Hz", "2kHz"), true));
	}

	@Override
	protected Object getID() {
		return OSAID.get();
	}

	@Override
	public void webRequestReceived(String line) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void addWebHandler(WebHandler myWebSocketHandler) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public String getServiceName() {
		return systemProperty.getApplicationType();
	}
	
	@Override
	protected RestSocket createRestSocket(String account, String password, ProxyData proxy) {
		return new RestSocketImpl("http://restmiyake.appspot.com/resources/");
	}
}
